package com.banciyuan.bcywebview.base.view.imageview;

import android.content.Context;
import android.util.AttributeSet;

import com.makeramen.roundedimageview.RoundedImageView;

//圆形头像，调用方法和普通ImageView一样
//是开源项目，请戳 https://github.com/hdodenhof/CircleImageView
public class CircleSquareImageView extends RoundedImageView {


    public CircleSquareImageView(Context context) {
        super(context);
    }

    public CircleSquareImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CircleSquareImageView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        setMeasuredDimension(getDefaultSize(0, widthMeasureSpec), getDefaultSize(0, heightMeasureSpec));

        int childWidthSize = getMeasuredWidth();
        //高度和宽度一样
        heightMeasureSpec = widthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY);
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
}